<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="icon" href="./images/hospital-icon.png" type="image/x-icon">  <!--在网页标题左侧显示图标-->
    <!--    <link rel="shortcut icon" href="./images/hospital-icon.png" type="image/x-svg">-->
    <link rel="shortcut icon" href="./images/hospital-icon.png" type="image/x-icon"><!--在收藏夹显示图标-->

    <title>登录-门诊管理系统</title>

    <link href="css/style.css" rel="stylesheet">
    <link href="css/iconfont.css" rel="stylesheet">
    <link href="css/style-responsive.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9] -->
    <script src="js/html5shiv.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

    <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>

</head>

<body class="login-body">

<div class="container" id="loginApp">

    <form class="form-signin"  @submit.prevent="login" method="post">
        <div class="form-signin-heading text-center">
            <h1 class="sign-title">账户登录</h1>
            <img style="width: 50px;height: 50px" src="images/hospital-icon.png" alt=""/>
            <span style="color: black;font-size: 26px;text-align: center;font-weight: 600;vertical-align: text-bottom">门诊管理系统</span>
        </div>


        <div id="error" class="alert alert-danger d-none" style="display: none">
            <i class="fa fa-exclamation-triangle"></i> 您的账号或密码错误
        </div>
        <div id="logout" class="alert alert-info d-none" style="display: none">
            <i class="fa fa-exclamation-triangle"></i>  您已登出系统
        </div>
        <div id="register" class="alert alert-success d-none" style="display: none">
            <i class="fa fa-exclamation-triangle"></i>  注册成功，请登录
        </div>

        <div class="login-wrap">
            <input v-model="oms_username" name="username" type="text" class="form-control" placeholder="请输入用户名" autofocus>
            <input v-model="oms_password" name="password" type="password" class="form-control" placeholder="请输入密码">

            <button class="btn btn-lg btn-login btn-block"  @submit.prevent="login" type="submit">
                <i class="fa fa-check"></i>
            </button>

            <div class="registration">
                还没有账号?
                <a class="" href="register.html">
                    点此注册
                </a>
            </div>

            <br>

        </div>

    </form>
</div>

<!--footer section start-->
<!--页脚部分开始-->
<footer style="position: fixed;bottom: 0;border: solid 0;background-color: rgb(0,0,0,0)">
    2022 &copy; <a href="https://gitee.com/allen-zc/OutpatientManagementSystem" target="_blank" style="color: #7a7676">基于SSM的门诊管理系统</a>
    -
    <a href="https://gitee.com/allen-zc" target="_blank" style="color: #7a7676">AllenChen曾晨</a>
    -
    <p style="display: inline-block">ALL RIGHTS RESERVED.</p>
</footer>
<!--footer section end-->
<!--页脚部分结束-->


<!-- Placed js at the end of the document so the pages load faster -->

<!-- Placed js at the end of the document so the pages load faster -->
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/modernizr.min.js"></script>

<script src="https://unpkg.zhimg.com/vue"></script>

<!--&lt;!&ndash; 开发环境版本，包含了有帮助的命令行警告 &ndash;&gt;-->
<!--<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>-->
<!--&lt;!&ndash; 生产环境版本，优化了尺寸和速度 &ndash;&gt;-->
<!--<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>-->
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>



<script>

    if (location.search == "?error"){
        $("#error").removeAttr("style");
    }
    if (location.search == "?logout"){
        $("#logout").removeAttr("style");
    }
    if (location.search == "?register"){
        $("#register").removeAttr("style");
    }
</script>

<script>
    // 登录
    let loginApp=new Vue({
        el:"#loginApp",
        data:{
            oms_username:"", // 登录用户名
            oms_password:"",    //登录密码

            remember:false, //记住密码
        },
        methods:{
            //账户登录
            login:function(){
                let form=new FormData();
                form.append("username",this.oms_username);
                form.append("password",this.oms_password);
                axios({
                    url:"/oms/api/login",
                    method:"post",
                    data:form
                }).then(function(res){
                    console.log(res.data);
                    // alert(res.data)
                    if (res.data.status==1){
                        // alert(res.data.status);
                        //将用户名存入缓存
                        window.localStorage.setItem("patientId",res.data.patientId);
                        // 跳转后端传过来的网页
                        location.href=res.data.url
                    }
                }).catch(function(error){
                    //登录失败运行这里,输出错误信息
                    console.log(error);
                })
            },

        },

    })

</script>

</body>
</html>
